(function() {

this.codium = this.codium || {};
this.codium.panel = this.codium.panel || {};

this.codium.panel.Login = pasta.webgui.Panel.extend(
{
	init : function() 
	{
		this._super();
		
		this.setWidth(700);
		this.setHeight(400);
		
		this.picLogo = new pasta.webgui.Picture();
		this.picLogo.setWidth(450);
		this.picLogo.setHeight(250);
		this.picLogo.setLeft(0);
		this.picLogo.setTop(0);
		this.picLogo.setImage(this.libDir + "/img/logoLogin.png");
		this.addControl(this.picLogo);
		
		this.panel = new pasta.webgui.Panel();
		this.panel.setLeft(270);
		this.panel.setTop(80);
		this.panel.setWidth(350);
		this.panel.setHeight(200);
		this.panel.setBgColor("rgba(0, 0, 0, 0.5)");
		this.panel.setBorderColor("rgba(255, 255, 255, 0.6)");
		this.panel.setShadow("0px 3px 6px #000000");
		this.addControl(this.panel);
		
			this.lblUserId = new pasta.webgui.Label();
			this.lblUserId.setLeft(20);
			this.lblUserId.setTop(30);
			this.lblUserId.setWidth(200);
			this.lblUserId.setCaption("User ID :");
			this.lblUserId.font.setColor("#FFFFFF");
			this.lblUserId.font.setBold(true);
			this.lblUserId.setShadow("0px 2px 4px #000000");
			this.panel.addControl(this.lblUserId);
			
			this.edtUserId = new pasta.webgui.Edit();
			this.edtUserId.setLeft(this.lblUserId.getLeft());
			this.edtUserId.setTop(this.lblUserId.getTop() + 22);
			this.edtUserId.setWidth(this.panel.getWidth() - (2 * this.edtUserId.getLeft()));
			this.edtUserId.getOnKeyDown().setHandler(this, this.edtUserIdKeyDown);
			this.panel.addControl(this.edtUserId);
			
			this.lblPass = new pasta.webgui.Label();
			this.lblPass.setLeft(20);
			this.lblPass.setTop(this.edtUserId.getTop() + 35);
			this.lblPass.setWidth(200);
			this.lblPass.setCaption("Password :");
			this.lblPass.font.setColor("#FFFFFF");
			this.lblPass.font.setBold(true);
			this.lblPass.setShadow("0px 2px 4px #000000");
			this.panel.addControl(this.lblPass);
			
			this.edtPass = new pasta.webgui.Edit();
			this.edtPass.setLeft(this.lblPass.getLeft());
			this.edtPass.setTop(this.lblPass.getTop() + 22);
			this.edtPass.setWidth(this.panel.getWidth() - (2 * this.edtPass.getLeft()));
			this.edtPass.setPassword(true);
			this.edtPass.getOnKeyDown().setHandler(this, this.edtPassKeyDown);
			this.panel.addControl(this.edtPass);
			
			this.btnLogin = new pasta.webgui.Button();
			this.btnLogin.setLeft(255);
			this.btnLogin.setTop(this.edtPass.getTop() + 35);
			this.btnLogin.setWidth(80);
			this.btnLogin.setCaption("Login");
			this.btnLogin.getOnClick().setHandler(this, this.btnLoginClick);
			this.panel.addControl(this.btnLogin);
	},	
	
	edtUserIdKeyDown : function(sender, key)
	{
		if (key == 13)
			this.edtPass.setFocus();
	},
	
	edtPassKeyDown : function(sender, key)
	{
		if (key == 13)
			this.btnLoginClick(this.btnLogin);
	},
	
	btnLoginClick : function(sender)
	{
		if (this._onLogin != null)
			this._onLogin.callHandler(this, this.edtUserId.getText(), this.edtPass.getText());
	},
	
	//-------------------- Service Event Handler --------------
	
	getOnLogin : function()
	{
		if (this._onLogin == null)
			this._onLogin = new pasta.util.EventObj();
		
		return this._onLogin;
	},
});

})();